<template>
  <app-page card full>
    <template #header>{{ $route.params.id ? '编辑设备' : '新增设备' }}</template>
    <el-form ref="pageForm" :model="pageState.detail" :style="'max-width:460px'" label-width="110px" @submit.prevent="pageActions.handleSubmit()">
      <jax-form-group :json="json" v-model="pageState.detail"></jax-form-group>
    </el-form>
    <template #footer>
      <div class="app-toolbar">
        <el-button type="default" @click="pageActions.handleCancel()">返回</el-button>
        <el-button type="primary" @click="pageActions.handleSubmit()">保存</el-button>
      </div>
    </template>
  </app-page>
</template>

<script setup>
import { computed } from 'vue'
import { usePageEdit } from 'jax-node'
const { pageState, pageActions, pageForm } = usePageEdit()

const fixed = false
const required = true
const miniInput = { style: 'width:100px' }
const json = computed(() => {
  return [
    {
      name: 'vipType',
      label: 'VIP类型',
      required,
      type: 'select',
      options: [
        { label: '年会员', value: 0 },
        { label: '天会员', value: 1 },
      ],
    },
  ]
})

/**
 * 保存前
 */
pageActions.handleBeforeSubmit = (detail) => {
  return {
    vipType: detail.vipType,
  }
}
</script>

<style lang="scss" scoped></style>
